package com.ruoyi.web.cp.service;

import com.ruoyi.web.core.config.ConfigLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;

@Service
public class WarnService {
    @Autowired
    private ConfigLoader configLoader;
    @Autowired
    private WinxinService winxinService;

    public void execute() {
        String rmPath = configLoader.getRmPath();
        String[] filePaths = {
                "fb-game.txt",
                "ob-game.txt",
                "rm-game.txt",
        };

        for (String filePath : filePaths) {
            File file = new File(rmPath + filePath);
            //判断file最后更新时间是否为最近10分钟
            if (file.lastModified() < System.currentTimeMillis() - 10 * 60 * 1000) {
//                winxinService.sendTextMessage("1000004", filePath.split("-")[0] + "异常");
                winxinService.sendTextMessage("1000004", filePath + "异常");
            }
        }
    }

}
